/*
 * Copyright (c) 2022-2023 Termony Co., Ltd. All rights reserved.
 *
 * This program is OPEN SOURCE software: you can redistribute it and/or modify it
 * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
 * either version 1.0 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the Phytium Public License for more details.
 *
 *
 * FilePath: sdmmc_system.h
 * Date: 2022-02-10 14:53:44
 * LastEditTime: 2022-02-25 11:46:22
 * Description:  This files is for sdmmc baremetal port
 *
 * Modify History:
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 * 1.0   zhugengyu  2022/11/15   init commit
 */

#ifndef SDMMC_SYSTEM_H
#define SDMMC_SYSTEM_H

#include "los_interrupt.h"
#include "los_compiler.h"
#include "los_debug.h"
#include <stddef.h>

#ifdef __cplusplus
extern "C"
{
#endif

/* Definitions for portable types. */
typedef INT32 sdmmc_err_t;
typedef UINT64 tick_type_t;

#define WORD_ALIGNED_ATTR           __attribute__((aligned(4)))
#define SDMMC_PTR_DMA_CAP(a)        !((unsigned long)a % 512)
#define MALLOC_8_ALIGN              (1U << 0)
#define MALLOC_32_ALIGN             (1U << 1)
#define MALLOC_64_ALIGN             (1U << 2)
#define MALLOC_256_ALIGN            (1U << 3)
#define MALLOC_512_ALIGN            (1U << 4)
#define MALLOC_CAP_DMA              MALLOC_512_ALIGN
#define MALLOC_CAP_DESC             MALLOC_256_ALIGN

#define SDMMC_PRINTF                printf
#define SDMMC_ASSERT(a)             LOS_ASSERT(a)

#define SDMMC_LOGE(fmt, args...)    LOS_Printf(LOG_MODULE_FS, LOG_ERR_LEVEL, fmt, ##args)
#define SDMMC_LOGW(fmt, args...)    LOS_Printf(LOG_MODULE_FS, LOG_WARN_LEVEL, fmt, ##args)
#define SDMMC_LOGI(fmt, args...)    LOS_Printf(LOG_MODULE_FS, LOG_INFO_LEVEL, fmt, ##args)
#define SDMMC_LOGD(fmt, args...)    LOS_Printf(LOG_MODULE_FS, LOG_DEBUG_LEVEL, fmt, ##args)
#define SDMMC_LOGV(fmt, args...)    LOS_Printf(LOG_MODULE_FS, LOG_COMMON_LEVEL, fmt, ##args)

void sdmmc_sys_delay_ms(uint32_t msecs);
void *sdmmc_sys_heap_caps_malloc(size_t size, uint32_t caps);
void sdmmc_sys_free(void *p);

#ifdef __cplusplus
}
#endif

#endif /* SDMMC_SYSTEM_H */